package com.contract.spirit.ui.system

import android.content.Context
import android.content.Intent
import com.contract.commonlib.util.ext.setOnSingleClickListener
import com.contract.commonlib.base.BaseActivity
import com.contract.spirit.BuildConfig
import com.contract.spirit.R
import com.contract.spirit.databinding.ActivityAboutBinding
import com.contract.spirit.manage.CommonConfigManager
import com.contract.spirit.ui.UserViewModel
import com.contract.spirit.ui.webview.CommonWebViewActivity

/**
 * @author: witness
 * created: 2021/9/29
 * desc:
 */
class AboutActivity : BaseActivity<ActivityAboutBinding,UserViewModel>() {
    override fun setContentView(): Int {
        return R.layout.activity_about
    }

    override fun initData() {
        mBinding.apply {
           versionName = String.format(
                "v%s%s",
                BuildConfig.VERSION_NAME,
                if (BuildConfig.isRelease) "" else "-" + BuildConfig.BUILD_TYPE
            )
            llServiceAgreement.setOnSingleClickListener {
                //用户协议
                CommonWebViewActivity.goLaunch(
                    mContext,
                    "用户协议",
                    CommonConfigManager.configInfoResponse.userAgreementUrl
                )
            }
            llAgreement.setOnSingleClickListener {
                CommonWebViewActivity.goLaunch(
                    mContext,
                    "隐私政策",
                    CommonConfigManager.configInfoResponse.privacyAgreementUrl
                )
            }
        }
    }
    companion object {
        fun launch(mContext: Context) {
            mContext.startActivity(Intent(mContext, AboutActivity::class.java))
        }
    }
}